
function showPaymentFee() {
   $("#rechargeAmount").val($("#rechargeAmount").val().replace(/\D+/g, ''));
   $("#chineseMoney").html(changeMoneyToChinese($("#rechargeAmount").val()));
}
$(function(){
	$('#recharge_form').submit(function(){
		var bank_id = $('#recharge_form input[name="bank_id"]:checked').val();
		if(!bank_id){
			//alert('请选择银行!');
			$.alert({
	    		status : 'error',
				basicTitle : '请选择银行!'
			});
			return false;
		}
		var amount = $('#recharge_form input[name="amount"]');
		if(amount.val() == ""){
			//alert('请输入充值金额!');
			$.alert({
	    		status : 'error',
				basicTitle : '请输入充值金额!'
			});
			return false;
		}
		var aval = parseInt(amount.val());
		if(aval < parseInt(amount.attr('min')) || aval > parseInt(amount.attr('max'))){
			//alert('单笔充值限额 最低： 1 元，最高： 100000 元 !');
			$.alert({
	    		status : 'error',
				basicTitle : '单笔充值限额 最低： 1 元，最高： 100000 元 !'
			});
			return false;
		}
		var onlinePayment=$('#recharge_form input[name="bank_id"]:checked').attr("onlinePayment");
		$.ajax({
			url 	: window.frontPath + "bank/recharge_submit",
			method 	: 'POST',
			data    : {
				bank_id: bank_id,
				amount: aval,
				onlinePayment:onlinePayment
			},
			success : function(data){
				if(onlinePayment == "Y"){
					$("#content-lottery").load(window.frontPath + 'content/bank/online_recharge?charge_id='+data.id);
				}else{
					$("#content-lottery").load(window.frontPath + 'content/bank/recharge_submit?charge_id='+data.id);
				}
			}
		});
		return false;
	});
	$('#tocash_form').submit(function(){
		var bank_id = $('#tocash_form input[name="bank_id"]:checked').val();
		if(!bank_id||!jQuery.trim(bank_id)){
			//alert('请选择银行!');
			$.alert({
	    		status : 'error',
				basicTitle : '请选择银行!'
			});
			return false;
		}
		var amount = $('#tocash_form input[name="amount"]');
		if(amount.val() == ""){
			//alert('请输入充值金额!');
			$.alert({
	    		status : 'error',
				basicTitle : '请输入充值金额!'
			});
			return false;
		}
		var aval = parseInt(amount.val());
		if(aval < parseInt(amount.attr('min')) || aval > parseInt(amount.attr('max'))){
			//alert('单笔提现限额 最低： 100 元，最高： 100000 元 !');
			$.alert({
	    		status : 'error',
				basicTitle : '单笔提现限额 最低： 100 元，最高： 100000 元 !'
			});
			return false;
		}
		var password = $('#tocash_form input[name="password"]').val();
		if(password == ""){
			//alert('请输入资金密码!');
			$.alert({
	    		status : 'error',
				basicTitle : '请输入资金密码!'
			});
			return false;
		}
		$.ajax({
			url 	: window.frontPath + "bank/tocash_submit",
			method 	: 'POST',
			data    : {
				bankName: $('#tocash_form input[name="bank_id"]:checked').attr("bankName"),
				amount: aval,
				password: password,
				openingName:$('#openingName').val(),
				uname:$('#uname').val(),
				account:$('#bank_account').val()
			},
			success : function(data){
				if(!data.success){
					//alert(data.message);
					$.alert({
			    		status : 'error',
						basicTitle : data.message
					});
				}else{
					$("#content-lottery").load(window.frontPath + 'content/bank/tocash_submit');
					location.hash = "/bank/tocash_submit";
					reloadUserInfo();
				}
			}
		});
		return false;
	});
	$('.bank-radio').click(function(){
		var _this = $(this);
		$('#bank_account').val(_this.attr('bank_account'));
		$('#uname').val(_this.attr('uname'));
		$('#openingName').val(_this.attr('openingName'));
	});
	$('.bank-radio:eq(0)').click(); 
});